import sys
sys.path.append("../..")
import pyrwi
import nidaqmx as DAQmx
import time

data = []
data.append([0,1,0,1,1,1,1,1])
data.append([1,0,1,0,0,0,0,0])

taskHandle = DAQmx.CreateTask("DigitalOut")
DAQmx.CreateDOChan(taskHandle,"Dev1/port0/line0:7","",DAQmx.Val_ChanForAllLines)

DAQmx.StartTask(taskHandle)
for d in data :
    DAQmx.WriteDigitalLines(taskHandle,1,1,10.0,DAQmx.Val_GroupByChannel,d,None)
    
    #Software timing is unreliable, but if timing is not too important
    #to you, you can do something like this.
    time.sleep(0.001)

#TODO: Watch last bit, make sure it changes
DAQmx.StopTask(taskHandle)
DAQmx.ClearTask(taskHandle)

print "Done"

